package com.atguigu.blog.exception;

import com.atguigu.blog.result.Result;
import com.atguigu.blog.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author CF
 * @date 2023/8/19 9:24
 */
@RestControllerAdvice
public class AtguiguExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e){
        return Result.fail();
    }

    @ExceptionHandler(AbstractException.class)
    public Result handleAbstractException(AbstractException e){
        ResultCodeEnum resultCodeEnum = e.getResultCodeEnum();
        return Result.build(null,resultCodeEnum);
    }
}
